package net.lanelife.casino.caipiao.service;

import java.util.List;

import net.lanelife.casino.caipiao.entity.RebatePointLevel;
import net.lanelife.casino.caipiao.entity.RebatePointLevel_;
import net.lanelife.casino.caipiao.repository.api.IRebatePointLevelRepository;
import net.lanelife.casino.caipiao.service.api.IRebatePointLevelService;
import net.lanelife.casino.common.repository.support.GenericRepository;
import net.lanelife.casino.common.service.support.GenericService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class RebatePointLevelService extends GenericService<RebatePointLevel, Integer> implements IRebatePointLevelService {

	@Autowired
	private IRebatePointLevelRepository repository;
	
	public RebatePointLevelService() {
		super(RebatePointLevel.class);
	}
	
	@Override
	protected GenericRepository<RebatePointLevel, Integer> getRepository() {
		return repository;
	}
	
	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<RebatePointLevel> findAll() {
		return super.findAll(new Sort(Direction.ASC, RebatePointLevel_.beginRebatePoint.getName()));
	}

	public RebatePointLevel findByRebatePoint(Double point) {
		return repository.findByBeginRebatePointLessThanEqualAndEndRebatePointGreaterThanEqual(point, point);
	}


}
